package com.offcn.search.controller;

import com.offcn.entity.Page;
import com.offcn.entity.Result;
import com.offcn.entity.StatusCode;
import com.offcn.search.pojo.SkuInfo;
import com.offcn.search.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author ld
 * @date 2021/9/14 15:28
 */
@RestController
@RequestMapping("/search")
@CrossOrigin
public class SkuController {

    @Autowired
    private SkuService skuService;

    /**
     * 导入数据
     * @return
     */
    @GetMapping("/imports")
    public Result imports() {
        skuService.importSku();
        return new Result(true, StatusCode.OK, "导入数据成功");
    }

    /**
     * 查询
     *
     * @return
     */
    @GetMapping("/search")
    public Result search(@RequestParam(required = false) Map<String, String> searchMap) {
        Map map = skuService.search(searchMap);

        return new Result(true, StatusCode.OK, "查询数据成功", map);
    }
}
